package com.hison.tandainbao.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hison.tandainbao.entiy.pojo.domain.TbJobType;
import com.hison.tandainbao.response.ResponseResult;
import com.hison.tandainbao.service.TbJobTypeService;
import com.hison.tandainbao.mapper.TbJobTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author hison
* @description 针对表【tb_job_type】的数据库操作Service实现
* @createDate 2024-03-30 16:02:39
*/
@Service
public class TbJobTypeServiceImpl extends ServiceImpl<TbJobTypeMapper, TbJobType>
implements TbJobTypeService{

    @Autowired
    private  TbJobTypeMapper mapper;
    @Override
    public ResponseResult getAllTypes() {
        List<TbJobType> list = query().list();
        if (list.size() <= 0 ){
            return  ResponseResult.error("查询结构为空");
        }
        return ResponseResult.ok(list);
    }

    @Override
    public ResponseResult deleteType(String typeId) {
        int i = mapper.deleteById(typeId);
        if (i < 1 ){
            return  ResponseResult.error("删除失败");
        }
        return ResponseResult.ok("删除成功");
    }

    @Override
    public ResponseResult updateType(TbJobType type) {
        boolean b = updateById(type);
        if (!b){
            return ResponseResult.error("更新失败");
        }
        return ResponseResult.ok("更新成功");
    }
}
